<template>
  <div class="app-container">
    <el-form :model="searchForm" :inline="true">
      <el-row>
        <el-col :span="18">
          <el-form-item prop="fuzzy">
            <el-input
              v-model="searchForm.fuzzy"
              style="width: 150px"
              placeholder="文件编号/名称"
            />
          </el-form-item>
          <el-form-item prop="classify">
            <el-select
              v-model="searchFormData.classify"
              style="width: 110px"
              placeholder="文件属性"
              @change="secondColumnChange($event)"
              value-key="id"
              clearable
            >
              <el-option
                v-for="item in fileProperties"
                :key="item.id"
                :label="item.name"
                :value="item"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="source">
            <el-select
              v-model="searchFormData.source"
              style="width: 110px"
              placeholder="文件来源"
              @change="secondColumn($event)"
              value-key="id"
              clearable
            >
              <el-option
                v-for="item in sourceOfTheFile"
                :key="item.id"
                :label="item.name"
                :value="item"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="type">
            <el-select
              v-model="searchForm.type"
              style="width: 110px"
              placeholder="文件类别"
              clearable
            >
              <el-option
                v-for="item in fileCategory"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="status">
            <el-select
              v-model="searchForm.status"
              style="width: 110px"
              placeholder="文件状态"
              clearable
            >
              <el-option
                v-for="item in fileStatus"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item prop="validity">
            <el-select
              v-model="searchForm.validity"
              style="width: 120px"
              placeholder="文件有效性"
              clearable
            >
              <el-option
                v-for="item in fileValidity"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>

          <el-form-item>
            <el-button
              type="primary"
              class="iconfont icon-chaxun1"
              size="small"
              @click="handleSearch"
            >
              查询</el-button
            >
          </el-form-item>
        </el-col>
        <el-col :span="6" class="search-right">
          <el-button type="text" @click="handleCreate">新增文件</el-button>
          <el-button type="text" @click="bulkRelease">批量发布</el-button>
          <el-button type="text" @click="bulkDelete">批量删除</el-button>
          <el-button type="text" @click="submissionReview"
            >批量提交审核</el-button
          >
        </el-col>
      </el-row>
    </el-form>

    <div>
      <el-table
        ref="stockTable"
        stripe
        border
        :data="factorData"
        class="table-item"
        highlight-current-row
        :header-cell-style="{ background: '#ECF3FC' }"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <template slot="empty">
          <div class="table_empty">
            <div class="empty_tips">
              <span> 暂无数据 </span>
            </div>
          </div>
        </template>
        <el-table-column
          type="selection"
          fixed="left"
          width="55"
          align="center"
        />
        <el-table-column type="index" width="70" align="center" label="序号" />
        <el-table-column
          prop="fileNo"
          label="文件编号"
          width="180"
          align="center"
        />
        <el-table-column
          prop="name"
          label="文件名称"
          width="180"
          align="center"
        />
        <el-table-column
          prop="classify"
          label="文件属性"
          width="110px"
          align="center"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.classify == '1'">受控文件</span>
            <span v-if="scope.row.classify == '2'">非受控文件</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="source"
          label="文件来源"
          width="100px"
          align="center"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.source == '1'"> 内部文件</span>
            <span v-if="scope.row.source == '2'">外部文件</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="type"
          label="文件类别"
          width="100"
          align="center"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.type == '1'">法律、法规和规章</span>
            <span v-if="scope.row.type == '2'">制度</span>
            <span v-if="scope.row.type == '3'">标准</span>
            <span v-if="scope.row.type == '4'">规定</span>
            <span v-if="scope.row.type == '5'">检测和校准方法</span>
            <span v-if="scope.row.type == '6'">图纸、图样</span>
            <span v-if="scope.row.type == '7'">软件</span>
            <span v-if="scope.row.type == '8'">说明书</span>
            <span v-if="scope.row.type == '9'">参考数据手册</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="version"
          label="版本号"
          width="180"
          align="center"
        />
        <el-table-column
          prop="safetyLevel"
          label="安全等级"
          width="120"
          align="center"
        />
        <el-table-column
          prop="release"
          label="发布机构"
          width="150px"
          align="center"
        />
        <el-table-column prop="remark" label="备注" width="140" align="center">
        </el-table-column>
        <el-table-column
          prop="createTime"
          label="创建日期"
          width="120"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="updateTime"
          label="更新日期"
          width="120"
          align="center"
        />

        <el-table-column
          prop="executeDate"
          label="实施日期"
          width="120"
          align="center"
        />
        <el-table-column
          prop="releaseDate"
          label="发布日期"
          width="120"
          align="center"
        />
        <el-table-column
          prop="checkUsers"
          label="审核人"
          width="150"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="validity"
          label="有效性"
          width="120"
          align="center"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.validity == '1'">现行</span>
            <span v-if="scope.row.validity == '2'">暂行</span>
            <span v-if="scope.row.validity == '3'">待实施</span>
            <span v-if="scope.row.validity == '4'">作废</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="status"
          label="文件状态"
          width="120"
          align="center"
        >
          <template slot-scope="scope">
            <span
              v-if="scope.row.status == '0'"
              style="background: #85888e;padding: 7px 15px; border-radius: 5px;color: #fff;"
              >草稿</span
            >
            <span
              v-if="scope.row.status == '1'"
              style="background: #1785ff;padding: 7px 15px; border-radius: 5px;color: #fff;"
              >待审核</span
            >
            <span
              v-if="scope.row.status == '2'"
              style="background: #13c85c;padding: 7px 15px; border-radius: 5px;color: #fff;"
              >审核通过</span
            >
            <span
              v-if="scope.row.status == '3'"
              style="background: #404b6e;padding: 7px 15px; border-radius: 5px;color: #fff;"
              >已发布</span
            >
            <span
              v-if="scope.row.status == '4'"
              style="background: #e90e0e;padding: 7px 15px; border-radius: 5px;color: #fff;"
              >已驳回</span
            >
          </template>
        </el-table-column>

        <el-table-column
          fixed="right"
          align="center"
          label="操作"
          width="200px"
        >
          <template slot-scope="scope">
            <el-button type="text" @click="previewArr(scope.row)">
              查看</el-button
            >
            <div class="erc-divider-vertical" />
            <el-button
              type="text"
              v-if="scope.row.status != '1'"
              @click="fileModification(scope.row)"
              >修改</el-button
            >
            <div class="erc-divider-vertical" v-if="scope.row.status == '2'" />
            <el-button
              type="text"
              v-if="scope.row.status == '2'"
              @click="filePublish(scope.row)"
              >发布</el-button
            >
            <div class="erc-divider-vertical" v-if="scope.row.status == '3'" />
            <el-button
              type="text"
              v-if="scope.row.status == '3'"
              @click="reviewStatus(scope.row)"
              >查阅状态</el-button
            >
            <div class="erc-divider-vertical" v-if="scope.row.status != '1'" />
            <el-button
              type="text"
              v-if="scope.row.status == '0' || scope.row.status == '4'"
              @click="submissionReviewarr(scope.row)"
              >提交审核</el-button
            >
            <div
              class="erc-divider-vertical"
              v-if="scope.row.status == '0' || scope.row.status == '4'"
            />
            <el-dropdown>
              <span class="el-dropdown-link"> 更多 </span>
              <el-dropdown-menu>
                <el-dropdown-item
                  ><el-button
                    type="text"
                    v-if="scope.row.status != '1'"
                    @click="historicalVersion(scope.row)"
                    >历史版本</el-button
                  ></el-dropdown-item
                >
                <el-dropdown-item
                  ><el-button type="text" @click="deletea(scope.row)"
                    >删除</el-button
                  ></el-dropdown-item
                >
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <div style="float: right">
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="searchForm.pageNumber"
        :limit.sync="searchForm.pageSize"
        @pagination="handleSearch"
      />
    </div>

    <!-- 新增文件弹框 -->
    <el-dialog
      :title="titleMap[orderDialogStatus]"
      :visible.sync="orderDialogVisible"
      center
    >
      <el-form ref="installForm" :model="installForm" :rules="rules">
        <el-card shadow="never">
          <div slot="header">
            <span>新增文件<i class="el-input__icon"/></span>
          </div>
          <el-row>
            <el-col :span="22">
              <el-form-item prop="name" label="文件名称:" label-width="100px">
                <el-input
                  v-model="installForm.name"
                  placeholder="请输入文件名称"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="11">
              <el-form-item prop="fileNo" label="文件编号:" label-width="100px">
                <el-input
                  v-model="installForm.fileNo"
                  placeholder="请输入文件编号"
                />
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item prop="version" label="版本号:" label-width="100px">
                <el-input
                  v-model="installForm.version"
                  placeholder="请输入版本号"
                >
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="11">
              <el-form-item
                prop="classify"
                label="文件属性:"
                label-width="100px"
              >
                <el-select
                  v-model="installForm.classify"
                  style="width: 100%"
                  placeholder="请输入文件属性"
                >
                  <el-option
                    v-for="item in fileProperties"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item prop="source" label="文件来源:" label-width="100px">
                <el-select
                  v-model="installForm.source"
                  style="width: 100%"
                  placeholder="文件来源"
                >
                  <el-option
                    v-for="item in sourceOfTheFile"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="11">
              <el-form-item prop="type" label="文件类别:" label-width="100px">
                <el-select
                  v-model="installForm.type"
                  style="width: 100%"
                  placeholder="请输入文件类别"
                >
                  <el-option
                    v-for="item in fileCategory"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item
                prop="release"
                label="发布机构:"
                label-width="100px"
              >
                <el-input
                  v-model="installForm.release"
                  placeholder="请输入发布机构"
                >
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="11">
              <el-form-item
                prop="safetyLevel"
                label="安全等级:"
                label-width="100px"
              >
                <el-select
                  v-model="installForm.safetyLevel"
                  style="width: 100%"
                  placeholder="请输入安全等级"
                >
                  <el-option
                    v-for="item in security"
                    :key="item.id"
                    :label="item.name"
                    :value="item.name"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item prop="file" label="文件上传:" label-width="100px">
                <el-upload
                  ref="waterImage"
                  class="upload-demo"
                  action="/api/file/fileUpload"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :before-remove="beforeRemove"
                  :on-change="customUploadChangeImage1"
                  :before-upload="beforeUpload"
                  accept=".doc,.docx,.pdf"
                  name="file"
                  multiple
                  :limit="1"
                  :on-exceed="handleExceedImage1"
                  :file-list="fileList"
                  @click="uploadFiles"
                >
                  <el-button size="small" type="primary" icon="el-icon-upload2"
                    >点击上传</el-button
                  >
                  <div slot="tip" class="el-upload__tip" style="color:red;">
                    （注：文件大小：小于50MB,文件格式:doc,docx,pdf）
                  </div>
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="11">
              <el-form-item
                prop="executeDate"
                label="实施日期:"
                label-width="100px"
              >
                <el-date-picker
                  v-model="installForm.executeDate"
                  style="width: 100%"
                  value-format="yyyy-MM-dd"
                  type="date"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item
                prop="releaseDate"
                label="发布日期:"
                label-width="100px"
              >
                <el-date-picker
                  v-model="installForm.releaseDate"
                  style="width: 100%"
                  value-format="yyyy-MM-dd"
                  type="date"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="11">
              <el-form-item
                prop="updateTime"
                label="更新日期:"
                label-width="100px"
              >
                <el-date-picker
                  v-model="installForm.updateTime"
                  style="width: 100%"
                  value-format="yyyy-MM-dd"
                  type="date"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="11">
              <el-form-item prop="validity" label="有效性:" label-width="100px">
                <el-select
                  v-model="installForm.validity"
                  style="width: 100%"
                  placeholder="请输入有效性"
                >
                  <el-option
                    v-for="item in fileValidity"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="22">
              <el-form-item prop="remark" label="备注:" label-width="100px">
                <el-input
                  v-model="installForm.remark"
                  type="textarea"
                  :rows="2"
                  show-word-limit
                  placeholder="备注"
                  maxlength="50"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="orderDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="confirmCreate">确认</el-button>
      </div>
    </el-dialog>
    <!-- 批量发布 -->
    <el-dialog
      title="选择人员"
      :visible.sync="addInvolvedUserIdVisible"
      center
      width="70%"
    >
      <!-- 人员选择 -->
      <personnelSelection
        ref="checked"
        :inputValue="inputName"
        @getSelectList="getSelectList"
      />
      <div slot="footer" class="dialog-footer">
        <el-button @click="addInvolvedUserIdVisible = false">取消</el-button>
        <el-button type="primary" @click="fileSending">文件发送</el-button>
      </div>
    </el-dialog>

    <!-- 文件提交审核 -->
    <el-dialog
      title="文件提交审核"
      :visible.sync="bulkSubmissionForReview"
      center
      width="38%"
    >
      <el-button type="primary" @click="selectReviewer">选择审核人员</el-button>

      <el-table
        ref="stockTable"
        stripe
        :data="selectData"
        class="table-item"
        highlight-current-row
        :header-cell-style="{ background: '#ECF3FC' }"
      >
        <template slot="empty">
          <div class="table_empty">
            <div class="empty_tips">
              <span> 暂无数据 </span>
            </div>
          </div>
        </template>
        <el-table-column
          prop="empName"
          label="姓名"
          width="180"
          align="center"
        />
        <el-table-column
          prop="deptName"
          label="部门"
          width="180"
          align="center"
        />

        <el-table-column
          prop="postNames"
          label="岗位"
          width="180"
          align="center"
        />

        <el-table-column
          fixed="right"
          align="center"
          label="操作"
          width="100px"
        >
          <template slot-scope="scope">
            <el-button
              type="text"
              @click.native.prevent="deleteRow(scope.$index, selectData)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button @click="bulkSubmissionForReview = false">取消</el-button>
        <el-button type="primary" @click="bulkReview">提交审核</el-button>
      </div>
    </el-dialog>

    <!-- 审核人员选择 -->
    <el-dialog
      title="审核人员选择"
      :visible.sync="reviewerSelection"
      center
      width="33%"
    >
      <el-table
        ref="stockTable"
        stripe
        :data="reviewer"
        class="table-item"
        highlight-current-row
        :header-cell-style="{ background: '#ECF3FC' }"
        @selection-change="reviewerChange"
      >
        <template slot="empty">
          <div class="table_empty">
            <div class="empty_tips">
              <span> 暂无数据 </span>
            </div>
          </div>
        </template>
        <el-table-column
          type="selection"
          fixed="left"
          width="35"
          align="center"
        />
        <el-table-column
          prop="empName"
          label="姓名"
          width="180"
          align="center"
        />
        <el-table-column
          prop="deptName"
          label="部门"
          width="180"
          align="center"
        />

        <el-table-column
          prop="postNames"
          label="岗位"
          width="180"
          align="center"
        />
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button @click="reviewerSelection = false">取消</el-button>
        <el-button type="primary" @click="reviewerarr">添加</el-button>
      </div>
    </el-dialog>

    <!-- 查阅状态 -->
    <el-dialog
      title="文件查阅状态"
      :visible.sync="reviewStatusVisible"
      center
      width="30%"
    >
      <div style="display: flex;justify-content: space-between;">
        <div style="width: 45%;">
          <el-table
            :data="readUsersData"
            height="350"
            style="width: 100%;color: #81A7C9;font-weight :600"
          >
            <el-table-column prop="username" label="文件已查阅员工" width="120">
            </el-table-column>
            <el-table-column prop="empName" label=""> </el-table-column>
          </el-table>
        </div>
        <div style="width: 45%">
          <el-table
            :data="unReadUsersData"
            height="350"
            style="width: 100%;color: #FD3232;font-weight :600"
          >
            <el-table-column prop="username" label="文件未查阅员工" width="120">
            </el-table-column>
            <el-table-column prop="empName" label=""> </el-table-column>
          </el-table>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="reviewStatusVisible = false">取消</el-button>
      </div>
    </el-dialog>

    <!-- 文件历史版本 -->
    <el-dialog
      title="文件历史版本 "
      :visible.sync="historicalVisible"
      center
      width="30%"
    >
      <el-table :data="historicalData" height="350" style="width: 100%;">
        <el-table-column prop="version" label="版本号" width="120" />
        <el-table-column prop="updateTime" label="更新日期" />
        <el-table-column prop="executeDate" label="实施日期" />
        <el-table-column
          fixed="right"
          align="center"
          label="操作"
          width="100px"
        >
          <template slot-scope="scope">
            <el-button type="text" @click="previewArr(scope.row)"
              >预览</el-button
            >
          </template>
        </el-table-column>
      </el-table>

      <div slot="footer" class="dialog-footer">
        <el-button @click="historicalVisible = false">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  fileList,
  add,
  update,
  vdelete,
  findAuditUser,
  submitVerify,
  publish,
  readList,
  versionList
} from "../components/index";
import personnelSelection from "../../../components/personnelSelection/personnelSelection.vue";

export default {
  components: { personnelSelection },
  data() {
    return {
      factorData: [], //数据
      total: 0,
      searchForm: {
        pageNumber: 1,
        pageSize: 10
      },
      searchFormData: {
        type: "",
        classType: ""
      },
      fileProperties: [
        {
          name: "受控文件",
          id: 1
        },
        {
          name: "非受控文件",
          id: 2
        }
      ],
      sourceOfTheFile: [
        {
          name: "内部文件",
          id: 1
        },
        {
          name: "外部文件",
          id: 2
        }
      ],
      fileCategory: [
        {
          name: "法律、法规和规章 ",
          id: 1
        },
        {
          name: "制度 ",
          id: 2
        },
        {
          name: "标准",
          id: 3
        },
        {
          name: "规定 ",
          id: 4
        },
        {
          name: "检测和校准方法 ",
          id: 5
        },
        {
          name: "图纸、图样  ",
          id: 6
        },
        {
          name: "软件 ",
          id: 7
        },
        {
          name: "说明书 ",
          id: 8
        },
        {
          name: "参考数据手册",
          id: 9
        }
      ],
      security: [
        {
          name: "1级",
          id: 1
        },
        {
          name: "2级",
          id: 2
        },
        {
          name: "3级",
          id: 3
        },
        {
          name: "4级",
          id: 4
        },
        {
          name: "5级",
          id: 5
        }
      ],
      fileStatus: [
        {
          name: "草稿",
          id: 0
        },
        {
          name: "待审核",
          id: 1
        },
        {
          name: "审核通过",
          id: 2
        },
        {
          name: "已发布",
          id: 3
        }
      ],
      fileValidity: [
        {
          name: "现行",
          id: 1
        },
        {
          name: "暂行",
          id: 2
        },
        {
          name: "待实施",
          id: 3
        },
        {
          name: "作废",
          id: 4
        }
      ],
      orderDialogStatus: "create",
      orderDialogVisible: false,
      titleMap: {
        edit: "文件修改",
        create: "新增文件"
      },
      rules: {
        name: [{ required: true, message: "请选择文件名称", trigger: "blur" }],
        version: [{ required: true, message: "请选择版本号", trigger: "blur" }],
        classify: [
          { required: true, message: "请选择文件属性", trigger: "blur" }
        ],
        source: [
          { required: true, message: "请选择文件来源", trigger: "blur" }
        ],
        type: [{ required: true, message: "请选择文件类别", trigger: "blur" }],
        safetyLevel: [
          { required: true, message: "请选择安全等级", trigger: "blur" }
        ],
        file: [{ required: true, message: "请上传文件", trigger: "blur" }],
        executeDate: [
          { required: true, message: "请选择实施日期", trigger: "blur" }
        ],
        releaseDate: [
          { required: true, message: "请选择发布日期", trigger: "blur" }
        ],
        validity: [{ required: true, message: "请选择有效性", trigger: "blur" }]
      },
      selection: [],
      selectionitem: [],
      multiplese: [],
      UserAdd: {
        fileIds: [],
        users: []
      },
      installForm: {
        name: "",
        fileNo: "",
        version: "",
        release: "",
        validity: "",
        remark: "",
        classify: "",
        source: "",
        executeDate: "",
        releaseDate: "",
        updateTime: "",
        url: "",
        id: ""
      },
      installarr: {},
      fileList: [],
      id: "",

      addInvolvedUserIdVisible: false,
      inputName: "",

      selectData: [],
      bulkSubmissionForReview: false,

      reviewerdata: [],
      reviewer: [],
      reviewerSelection: false,
      submitVerifydata: {},
      selectionitemReviewer: [],

      reviewStatusVisible: false,
      review: {},
      readUsersData: [],
      unReadUsersData: [],

      historicalVisible: false,
      historicalData: []
    };
  },
  created() {
    this.handleSearch();
  },
  methods: {
    handleSearch() {
      fileList(this.searchForm).then(res => {
        if (res.code === 200) {
          this.factorData = res.result.records;
          this.total = res.result.total;
          // console.log(this.factorData);
        }
      });
    },

    // 获取列表勾中id
    handleSelectionChange(val) {
      console.log(val);
      this.multiplese = val;
      var arr = [];
      var arr1 = [];
      for (var item of val) {
        arr.push(item.id);
        arr1.push(item);
        console.log(arr1);
        this.Selection = arr;
        this.selectionitem = arr1;
      }
    },
    // 新增文件
    handleCreate() {
      this.installForm.id = "";
      this.installForm = {};
      this.fileList = [];
      this.orderDialogStatus = "create";
      this.orderDialogVisible = true;
    },
    // 新增确认
    confirmCreate() {
      console.log(this.installForm.id);
      if (this.installForm.id != undefined) {
        console.log("修改");
        this.installarr.id = this.installForm.id;
        this.installarr.fileNo = this.installForm.fileNo;
        this.installarr.name = this.installForm.name;
        this.installarr.classify = this.installForm.classify;
        this.installarr.source = this.installForm.source;
        this.installarr.type = this.installForm.type;
        this.installarr.version = this.installForm.version;
        this.installarr.safetyLevel = this.installForm.safetyLevel;
        this.installarr.release = this.installForm.release;
        this.installarr.remark = this.installForm.remark;
        this.installarr.updateTime = this.installForm.updateTime;
        this.installarr.releaseDate = this.installForm.releaseDate;
        this.installarr.executeDate = this.installForm.executeDate;
        this.installarr.validity = this.installForm.validity;
        this.installarr.url = this.installForm.url;
        update(this.installarr)
          .then(result => {
            if (result.code === 200) {
              this.$notify({
                title: "成功",
                message: result.message,
                type: "success"
              });
              this.installForm = {};
              this.handleSearch();
              this.orderDialogVisible = false;
            } else {
              this.$notify({
                title: "失败",
                message: result.message,
                type: "error"
              });
            }
          })
          .catch(() => {});
      } else {
        console.log("新增");
        add(this.installForm)
          .then(result => {
            if (result.code === 200) {
              this.$notify({
                title: "成功",
                message: result.message,
                type: "success"
              });
              this.installForm = {};
              this.handleSearch();
              this.orderDialogVisible = false;
            } else {
              this.$notify({
                title: "失败",
                message: result.message,
                type: "error"
              });
            }
          })
          .catch(() => {});
      }
    },

    //修改
    fileModification(row) {
      console.log(row);
      this.fileList = [];
      this.installForm = row;

      var name = {};
      this.name = row.url.split("/")[0];
      this.$set(name, "name", this.name);
      this.fileList.push(name);
      console.log(this.fileList);
      this.orderDialogStatus = "edit";
      this.orderDialogVisible = true;
    },

    filePublish(row) {
      this.UserAdd.fileIds = row.id.split(",");
      this.addInvolvedUserIdVisible = true;
    },

    //批量发布
    bulkRelease() {
      if (this.multiplese && this.multiplese.length > 0) {
        this.selectionitem.forEach(item => {
          if (item.status === 2 || item.status === 3) {
            this.inputName = "";
            this.addInvolvedUserIdVisible = true;
            this.UserAdd.fileIds = this.Selection;
          } else {
            this.$message.info("请选择状态为“审核通过”或“已发布”的文件");
          }
        });
      } else {
        this.$message.info("最少选择一条文件信息");
      }
    },

    //子组件传的数据
    getSelectList(value) {
      console.log(value);
      // this.userName = "";
      // this.userName = value.map(item => item.nickName);
      this.UserAdd.users = value.map(item => item.id);
    },

    fileSending() {
      publish(this.UserAdd).then(result => {
        if (result.code === 200) {
          this.$notify({
            title: "成功",
            message: result.message,
            type: "success"
          });
          this.inputName = "";
          this.addInvolvedUserIdVisible = false;
          this.handleSearch();
        } else {
          this.$notify({
            title: "失败",
            message: result.message,
            type: "error"
          });
        }
      });
    },

    // 文件上传
    beforeUpload(e) {
      // console.log(e);
      this.file = e;
    },
    uploadFiles(e) {
      // console.log(e.target.file);
    },
    handleRemove(file, fileList) {
      // console.log(file, fileList);
    },
    handlePreview(file) {
      // console.log(file);
    },
    handleExceedImage1(file, fileList) {
      // console.log(file);
      this.$message.warning(
        `当前限制选择 1 个文件，已选 ${file.length} 个文件`
      );
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    //上传文件1
    customUploadChangeImage1(file) {
      console.log(file);
      if (file.status === "ready") return;
      if (file.status === "success") {
        const res = file.response || {};
        if (res && res.code === 200) {
          this.installForm.url = file.response.result;
          // console.log(this.installForm.addDeviceInstallTdo.image2);
          this.$message({
            type: "success",
            message: "上传成功!"
          });
        } else {
          this.$message.error("上传失败!");
          this.fileList = [];
        }
      } else {
        this.$message.error("上传失败!");
        this.fileList = [];
      }
    },
    //单个删除
    deletea(row) {
      this.id = row.id;
      this.handleDelete();
    },
    //批量删除
    bulkDelete() {
      if (this.multiplese && this.multiplese.length > 0) {
        this.id = this.Selection.join(",");
        this.handleDelete();
      } else {
        this.$message.info("最少选择一条文件信息");
      }
    },
    /** 删除按钮操作 */
    handleDelete() {
      this.$confirm("是否确认删除当前数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          vdelete({ ids: this.id }).then(result => {
            if (result.code === 200) {
              this.$notify({
                title: "成功",
                message: result.message,
                type: "success"
              });
              this.handleSearch();
            } else {
              this.$notify({
                title: "失败",
                message: result.message,
                type: "error"
              });
            }
          });
        })
        .catch(() => {});
    },
    // 获取人员勾中id
    reviewerChange(val) {
      var arr = [];
      var arr1 = [];
      for (var item of val) {
        arr.push(item.userId);
        arr1.push(item);
        this.reviewerdata = arr;
        this.selectionitemReviewer = arr1;
      }
    },
    //单个提交审核弹框
    submissionReviewarr(row) {
      if (row.status === 0 || row.status === 4) {
        this.selectData = [];
        this.submitVerifydata.ids = row.id.split(",");
        this.bulkSubmissionForReview = true;
      } else {
        this.$message.info("请选择状态为“草稿”或“已驳回”的文件");
      }
    },
    //批量提交审核弹框
    submissionReview() {
      if (this.multiplese && this.multiplese.length > 0) {
        this.selectData = [];
        this.selectionitem.forEach(item => {
          if (row.status === 0 || row.status === 4) {
            this.submitVerifydata.ids = this.Selection;
            this.bulkSubmissionForReview = true;
          } else {
            this.$message.info("请选择状态为“草稿”或“已驳回”的文件");
          }
        });
      } else {
        this.$message.info("最少选择一条文件信息");
      }
    },
    //提交审核
    bulkReview() {
      this.submitVerifydata.users = this.reviewerdata;
      submitVerify(this.submitVerifydata).then(result => {
        if (result.code === 200) {
          this.$notify({
            title: "成功",
            message: result.message,
            type: "success"
          });
          this.bulkSubmissionForReview = false;
          this.reviewerdata = [];
          this.Selection = [];
          this.handleSearch();
        } else {
          this.$notify({
            title: "失败",
            message: result.message,
            type: "error"
          });
        }
      });
    },
    //选择审核人员
    selectReviewer() {
      this.reviewerdata = [];
      this.Selection = [];
      findAuditUser().then(res => {
        if (res.code === 200) {
          this.reviewer = res.result;
        }
      });
      this.reviewerSelection = true;
    },

    // 人员添加
    reviewerarr() {
      this.selectData = this.selectionitemReviewer;
      this.reviewerSelection = false;
    },

    deleteRow(index, rows) {
      rows.splice(index, 1);
      var arr = [];
      rows.forEach(item => {
        arr.push(item.userId);
      });
      this.reviewerdata = arr;
      this.selectData = rows;
    },

    // 查阅状态
    reviewStatus(row) {
      console.log(row);
      this.review.fileId = row.id;
      this.review.version = row.version;
      readList(this.review).then(res => {
        if (res.code === 200) {
          this.readUsersData = res.result.readUsers;
          this.unReadUsersData = res.result.unReadUsers;
        }
      });
      this.reviewStatusVisible = true;
    },

    //历史版本
    historicalVersion(row) {
      console.log(row);
      versionList({ fileId: row.id }).then(res => {
        if (res.code === 200) {
          this.historicalData = res.result;
        }
      });
      this.historicalVisible = true;
    },

    previewArr(row) {
      console.log(row);
      if (row.url != undefined && row.url != "") {
        var url = "https://www.huancelian.com/file" + row.url;
        window.open(url);
      } else {
        this.$message.warning(`请上传文件`);
      }
    }
  }
};
</script>

<style scoped lang="scss" type="text/scss">
.search_div {
  > div {
    &:nth-child(1) {
      margin-right: 10px;
    }
    display: inline-block;
  }
}

.search_input {
  width: 200px;
  margin-bottom: 5px;
}
.search-right {
  text-align: right;
  padding-right: 25px;
}
.item {
  font-size: 16px;
}
::v-deep .el-card .el-card__header {
  padding: 5px 20px;
  background: #f3f2f2;
}
.block-flex {
  position: relative;
  display: flex;
  & > div {
    border: 1px solid #b7b7b7;
    width: 100px;
    margin: 0;
    line-height: 30px;
    text-align: center;
  }
  & > div:first-child {
    background: #b7b7b7;
  }
}
.card-left {
  width: 100%;
  min-height: 200px;
  max-height: 450px;
}
.card-right {
  width: 100%;
  min-height: 200px;
  max-height: 450px;
}
.el-card {
  overflow: auto;
}
.el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}
.el-icon-arrow-down {
  font-size: 14px;
}
// /deep/.main-body .el-table__header-wrapper  .el-checkbox{
//   display:none
// }
.agreement_picture {
  min-height: calc(100%);
  .pdf {
    height: calc(100%);
  }
}

/deep/ .el-input.is-disabled .el-input__inner {
  color: unset;
}

/deep/.i-input .el-input__inner {
  text-align: center;
}
/deep/.right-input .el-input__inner {
  text-align: right;
}

.el-header {
  line-height: 45px;
  height: 45px;
}
.el-footer {
  text-align: right;
  line-height: 45px;
  height: 45px;

  .pagination-container {
    padding: 0;
    margin-top: 10px;
    margin-bottom: 45px;
  }
}
.el-main {
  overflow-y: auto;
}
.el-container {
  max-height: 450px;
}
</style>
<style scoped>
.text {
  font-size: 14px;
}
.dialog-item {
  padding-left: 3px;
  line-height: 30px;
  cursor: pointer;
}
.dialog-item:hover {
  background: #e8f4ff;
  border-radius: 3px;
}

table {
  background-color: transparent;
}

caption {
  padding-top: 8px;
  padding-bottom: 8px;
  color: #777;
  text-align: left;
}

th {
  text-align: left;
}

.table {
  width: 100%;
  max-width: 100%;
  margin-bottom: 20px;
}

.table > tbody > tr > td,
.table > tbody > tr > th,
.table > tfoot > tr > td,
.table > tfoot > tr > th,
.table > thead > tr > td,
.table > thead > tr > th {
  padding: 8px;
  line-height: 1.42857143;
  vertical-align: middle;
  border-top: 1px solid #ddd;
}

.table > thead > tr > th {
  vertical-align: bottom;
  border-bottom: 2px solid #ddd;
}

.table > caption + thead > tr:first-child > td,
.table > caption + thead > tr:first-child > th,
.table > colgroup + thead > tr:first-child > td,
.table > colgroup + thead > tr:first-child > th,
.table > thead:first-child > tr:first-child > td,
.table > thead:first-child > tr:first-child > th {
  border-left: 1px solid #f1f2f4;
}

.table > tbody + tbody {
  border-top: 2px solid #ddd;
}

.table .table {
  background-color: #fff;
}

.table-condensed > tbody > tr > td,
.table-condensed > tbody > tr > th,
.table-condensed > tfoot > tr > td,
.table-condensed > tfoot > tr > th,
.table-condensed > thead > tr > td,
.table-condensed > thead > tr > th {
  padding: 5px;
}

.table-bordered {
  border: 1px solid #ddd;
}

.table-bordered > tbody > tr > td,
.table-bordered > tbody > tr > th,
.table-bordered > tfoot > tr > td,
.table-bordered > tfoot > tr > th,
.table-bordered > thead > tr > td,
.table-bordered > thead > tr > th {
  border: 1px solid #ddd;
}

.table-bordered > thead > tr > td,
.table-bordered > thead > tr > th {
  border-bottom-width: 2px;
}

.table-striped > tbody > tr:nth-of-type(odd) {
  background-color: #f9f9f9;
}

.table-hover > tbody > tr:hover {
  background-color: #f5f5f5;
}

table col[class*="col-"] {
  position: static;
  display: table-column;
  float: none;
}

table td[class*="col-"],
table th[class*="col-"] {
  position: static;
  display: table-cell;
  float: none;
}

.table > tbody > tr.active > td,
.table > tbody > tr.active > th,
.table > tbody > tr > td.active,
.table > tbody > tr > th.active,
.table > tfoot > tr.active > td,
.table > tfoot > tr.active > th,
.table > tfoot > tr > td.active,
.table > tfoot > tr > th.active,
.table > thead > tr.active > td,
.table > thead > tr.active > th,
.table > thead > tr > td.active,
.table > thead > tr > th.active {
  background-color: #f5f5f5;
}

.table-hover > tbody > tr.active:hover > td,
.table-hover > tbody > tr.active:hover > th,
.table-hover > tbody > tr:hover > .active,
.table-hover > tbody > tr > td.active:hover,
.table-hover > tbody > tr > th.active:hover {
  background-color: #e8e8e8;
}

.table > tbody > tr.success > td,
.table > tbody > tr.success > th,
.table > tbody > tr > td.success,
.table > tbody > tr > th.success,
.table > tfoot > tr.success > td,
.table > tfoot > tr.success > th,
.table > tfoot > tr > td.success,
.table > tfoot > tr > th.success,
.table > thead > tr.success > td,
.table > thead > tr.success > th,
.table > thead > tr > td.success,
.table > thead > tr > th.success {
  background-color: #dff0d8;
}

.table-hover > tbody > tr.success:hover > td,
.table-hover > tbody > tr.success:hover > th,
.table-hover > tbody > tr:hover > .success,
.table-hover > tbody > tr > td.success:hover,
.table-hover > tbody > tr > th.success:hover {
  background-color: #d0e9c6;
}

.table > tbody > tr.info > td,
.table > tbody > tr.info > th,
.table > tbody > tr > td.info,
.table > tbody > tr > th.info,
.table > tfoot > tr.info > td,
.table > tfoot > tr.info > th,
.table > tfoot > tr > td.info,
.table > tfoot > tr > th.info,
.table > thead > tr.info > td,
.table > thead > tr.info > th,
.table > thead > tr > td.info,
.table > thead > tr > th.info {
  background-color: #d9edf7;
}

.table-hover > tbody > tr.info:hover > td,
.table-hover > tbody > tr.info:hover > th,
.table-hover > tbody > tr:hover > .info,
.table-hover > tbody > tr > td.info:hover,
.table-hover > tbody > tr > th.info:hover {
  background-color: #c4e3f3;
}

.table > tbody > tr.warning > td,
.table > tbody > tr.warning > th,
.table > tbody > tr > td.warning,
.table > tbody > tr > th.warning,
.table > tfoot > tr.warning > td,
.table > tfoot > tr.warning > th,
.table > tfoot > tr > td.warning,
.table > tfoot > tr > th.warning,
.table > thead > tr.warning > td,
.table > thead > tr.warning > th,
.table > thead > tr > td.warning,
.table > thead > tr > th.warning {
  background-color: #fcf8e3;
}

.table-hover > tbody > tr.warning:hover > td,
.table-hover > tbody > tr.warning:hover > th,
.table-hover > tbody > tr:hover > .warning,
.table-hover > tbody > tr > td.warning:hover,
.table-hover > tbody > tr > th.warning:hover {
  background-color: #faf2cc;
}

.table > tbody > tr.danger > td,
.table > tbody > tr.danger > th,
.table > tbody > tr > td.danger,
.table > tbody > tr > th.danger,
.table > tfoot > tr.danger > td,
.table > tfoot > tr.danger > th,
.table > tfoot > tr > td.danger,
.table > tfoot > tr > th.danger,
.table > thead > tr.danger > td,
.table > thead > tr.danger > th,
.table > thead > tr > td.danger,
.table > thead > tr > th.danger {
  background-color: #f2dede;
}

.table-hover > tbody > tr.danger:hover > td,
.table-hover > tbody > tr.danger:hover > th,
.table-hover > tbody > tr:hover > .danger,
.table-hover > tbody > tr > td.danger:hover,
.table-hover > tbody > tr > th.danger:hover {
  background-color: #ebcccc;
}

.table-responsive {
  min-height: 3.01%;
  overflow-x: auto;
}

.table-bordered,
.table-bordered > tbody > tr > td,
.table-bordered > tbody > tr > th,
.table-bordered > tfoot > tr > td,
.table-bordered > tfoot > tr > th,
.table-bordered > thead > tr > td,
.table-bordered > thead > tr > th {
  border: 1px solid #e9ecef;
  text-align: center;
  line-height: 14px;
}

.table-bordered,
td,
th {
  border-radius: 0 !important;
}

.table-bordered > tbody > tr:last-child > td {
  border-bottom: 1px solid #e9ecef;
}

.bootstrap-table .fixed-table-container .fixed-table-header {
  overflow: hidden;
  background: rgba(0, 0, 0, 0.05);
}

.fixed-table-header .table > thead > tr {
  background: none !important;
}

.table > thead > tr {
  color: #636363;
  font-weight: 400;
  background: rgba(0, 0, 0, 0.05);
  /*   background: repeat-x #fafafa;
  background-image: -webkit-linear-gradient(top,#F8F8F8 0,#fafafa 100%);
  background-image: -o-linear-gradient(top,#F8F8F8 0,#fafafa 100%);
  background-image: linear-gradient(to bottom,#F8F8F8 0,#fafafa 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff8f8f8', endColorstr='#ffececec', GradientType=0); */
}

.table > thead > tr > th {
  border-color: #e9ecef;
  font-weight: 700;
  border-right-color: transparent;
}

.table > thead > tr > th .ace-icon:first-child {
  margin-right: 2px;
}

.table > thead > tr > th:first-child {
  border-left-color: #f1f1f1;
}

.table > thead > tr > th:last-child {
  border-right-color: #f1f1f1;
}

.table.table-bordered > thead > tr > th {
  vertical-align: middle;
}

td.center,
th.center {
  text-align: center;
}

td .lbl,
th .lbl {
  margin-bottom: 0;
}

td .lbl:only-child,
th .lbl:only-child {
  vertical-align: top;
}

.table-header {
  background-color: #307ecc;
  color: #fff;
  font-size: 14px;
  line-height: 38px;
  padding-left: 12px;
  margin-bottom: 1px;
}

.table-header .close {
  margin-right: 8px;
  margin-top: 0;
  opacity: 0.45;
  filter: alpha(opacity=45);
}

.table-header .close:hover {
  opacity: 0.75;
  filter: alpha(opacity=75);
}

th.detail-col {
  width: 48px;
  text-align: center;
}

tr.detail-row {
  display: none;
}

tr.detail-row.open {
  display: block;
  display: table-row;
}

tr.detail-row > td {
  background-color: #f1f6f8;
  border-top: 3px solid #d1e1ea !important;
}

.table-detail {
  background-color: #fff;
  border: 1px solid #dcebf7;
  width: 100%;
  padding: 12px;
}

.table-detail td > .profile-user-info {
  width: 100%;
}
</style>
